package com.pctx.bibatracker.service.impl;

import com.pctx.bibacommon.result.Result;
import com.pctx.bibatracker.dao.AlarmMapper;
import com.pctx.bibatracker.pojo.Alarm;
import com.pctx.bibatracker.service.AlarmService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("/alarmService")
public class AlarmServiceImpl implements AlarmService {
    @Autowired
    private AlarmMapper alarmMapper;

    /**
     * 报警
     *
     * @param deviceNo
     * @return
     * @throws Exception
     */
    @Override
    public Result selectAlarm(String deviceNo) throws Exception {
        if(StringUtils.isEmpty(deviceNo)){
           return Result.error("参数不能为空");
        }
        List<Alarm> alarm = alarmMapper.selectByDeviceUuid(deviceNo);
        System.out.println(alarm);
        if (alarm != null) {
            return Result.success(alarm, "报警信息获得");
        } else {
            return Result.error("无报警信息");
        }


    }
}
